﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

namespace Nirvana
{
    [AddComponentMenu("Nirvana/UI/Bind/Variable Bind Image Bool")]
    [RequireComponent(typeof(Image))]
    public class UIVariableBindImageBool : UIVariableBindBool
    {
        [Tooltip("The sprite used when the boolean is true.")]
        [SerializeField]
        private Sprite on;

        [Tooltip("The sprite used when the boolean is false.")]
        [SerializeField]
        private Sprite off;


        private Image _image;

        protected override void OnValueChanged()
        {
            if (this._image == null)
            {
                this._image = base.GetComponent<Image>();
            }
            if (base.GetResult())
            {
                this._image.sprite = this.on;
            }
            else
            {
                this._image.sprite = this.off;
            }
        }

    }
}

